package com.example.blog.common.pojo;

import com.example.blog.common.enums.ResultStatusEnum;
import lombok.Data;

@Data
//统一结果返回的result
public class Result<T> {
    private int code;//状态码
    private String errMsg;//错误信息
    private T data;//具体真实的数据

//方法
    public static<T> Result<T> ok(T data){
        Result result=new Result();
        result.setCode(ResultStatusEnum.SUCCESS.getCode());
        result.setErrMsg("");
        result.setData(data);
        return result;
    }
    public static<T> Result<T> fail(String errMsg){
        Result result=new Result();
        result.setCode(ResultStatusEnum.FATL.getCode());
        result.setErrMsg(errMsg);
        //result.setData(data);
        return result;
    }
}
